#include <stdio.h>

char decimalToHex(int decimalNum) {
	char hexChar;
	int high = decimalNum / 16;  // 获取十六进制的十位
	int low = decimalNum % 16;   // 获取十六进制的个位

	if (high >= 0 && high <= 9) {
		hexChar = '0' + high;  // 如果是0-9的数字，直接转换为对应的字符
	} else if (high >= 10 && high <= 15) {
		hexChar = 'A' + (high - 10);  // 如果是10-15的数字，转换为A-F的字符
	} else {
		hexChar = '0';  // 其他情况返回0
	}

	if (low >= 0 && low <= 9) {
		hexChar = hexChar * 10 + '0' + low;  // 如果是0-9的数字，直接转换为对应的字符
	} else if (low >= 10 && low <= 15) {
		hexChar = hexChar * 10 + 'A' + (low - 10);  // 如果是10-15的数字，转换为A-F的字符
	} else {
		hexChar = hexChar * 10 + '0';  // 其他情况返回0
	}

	return hexChar;
}

int main() {
	int decimalNumber = 56;
	char hexValue = decimalToHex(decimalNumber);
	printf("Hexadecimal value: 0x%02x\n", hexValue);
	return 0;
}
